import router from "@/router";
import {toast} from "vant"
import {teams,subordinates,subordinate,articlesdes,teamusers} from "@/server/team";
import {setStorage,setSession,removeStorage} from "@/utils/common";
export default {
  state: () => ({
    teamdescription:""
  }),
  mutations: {
    setteamdescription(state,data){
        state.teamdescription=data
      }
  },
  actions: {
    teams({commit},data){
        return new Promise((resolve,reject)=>{
            teams(data).then(res=>{
                if(res.code==0){
                    // commit("setlist",res.data)
                    if(res.data.list.length!==0){
                        resolve(res.data)
                    }else{
                        resolve(res.data)
                    }
                }else{
                    Toast(res.msg);
                  }
            })
        })  
    },
    subordinates({commit},data){
        return new Promise((resolve,reject)=>{
            subordinates(data).then(res=>{
                if(res.code==0){
                    resolve(res.data)
                }else{
                    Toast(res.msg);
                  }
            })
        })  
    },
    articlesdes({ commit }, data) {
        return new Promise((resolve, reject) => {
          articlesdes(data).then((res) => {
            if (res.code == 0) {
              commit("setteamdescription",res.data)
              resolve(res.data);
            } else {
              Toast(res.msg);
            }
          });
        });
      },
      teamusers({commit},data){
        return new Promise((resolve,reject)=>{
          teamusers(data).then(res=>{
              if(res.code==0){
                  resolve(res.data)
              }else{
                  Toast(res.msg);
                }
          })
      }) 
      }
  },
  getters: {},
};